package com.fulihui.information.biz.counter;

import com.fulihui.information.core.db.CategoryStatisticsDB;
import com.fulihui.information.core.db.ContentCounterDB;
import com.fulihui.information.model.UserContentOperate;
import org.springframework.stereotype.Component;

/**
 * 用户评论计数器
 *
 * @author Willard.Hu on 2017/1/10 0010.
 */
@Component("contentCommentTimesOperableCounter")
public class ContentCommentTimesOperableCounter extends AbstractContentOperableCounter {

    @Override
    public Long count(String contentId) {
        return contentCounterDB.singleTimes(ContentCounterDB.CounterType.COMMENT_TIMES, contentId);
    }

    @Override
    public Long operate(UserContentOperate userContentOperate) {
        // 类目统计
        incrCategoryStatistics(userContentOperate.getContentId(),
                CategoryStatisticsDB.StatisticType.COMMENT_TIMES);
        return contentCounterDB.incr(ContentCounterDB.CounterType.COMMENT_TIMES,
                userContentOperate.getContentId());
    }
}
